package per.yhh.xxxtsj.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import per.yhh.xxxtsj.Handler.OptionInterceptor;


@Configuration
@ComponentScan(basePackages = "per.yhh.xxxtsj") //全局异常处理类需要被扫描才能
public class WebMvcConfig implements WebMvcConfigurer {


    @Bean
    OptionInterceptor getOptionInterceptor() {
        return new OptionInterceptor();
    }

    /**
     * 注册自定义拦截器
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getOptionInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/login");//开放登录路径
    }
}
